#include <qcustomplot.h>
class MyCustomPlot : public QCustomPlot
{
    Q_OBJECT

public:
    enum MouseLeftButtonModel
    { // 鼠标左键拖动模式
        Select,
        Drag
    };
    MyCustomPlot(QWidget *parent = nullptr);
    MouseLeftButtonModel model() const
    {
        return mModel;
    }
    void setSelectModel();
    void setDragModel();
    // 设置测量线,只能在数据很坐标轴范围内使用
    void setLeftLine(double left);
    void setRightLine(double right);
    void setLeftRightLine(double left, double right);
    void setMeasureLineVisible(bool visible);
    double leftLine();
    double rightLine();
signals:
    void leftLineChanged(double v);
    void rightLineChanged(double v);
protected:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void paintEvent(QPaintEvent *event) override;
private:
    MouseLeftButtonModel mModel = Select;
    QCPItemLine *mVerticalLineLeft = nullptr;
    QCPItemLine *mVerticalLineRight = nullptr;
};
